package com.example.javabase.ScriptEngineManager;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * @author: wyb
 * @date: 2021/11/4 10:22
 * @describe:
 * @vision 1.0
 */
@Slf4j
public class Test2 {

    public static void main(String[] args) throws ScriptException {
        HashMap<String, Object> factInfo = new HashMap<>();
        factInfo.put("1","hello");
        factInfo.put("2","2");
        factInfo.put("3","你好");
        factInfo.put("4","4");
        for (Map.Entry<String,Object> obj :factInfo.entrySet()) {
            String key = obj.getKey();
            String value = obj.getValue().toString();
            if(Strings.isEmpty(value)){
                continue;
            }
            try {
                BigDecimal bigDecimal = new BigDecimal(value);
                factInfo.put(key,bigDecimal);
            } catch (Exception e) {
                log.info("该指标的值是汉字，无需转换...");
            }
        }
        System.out.println(factInfo);
    }
    public String getDate(Integer year,Integer month, Integer day) {
        SimpleDateFormat sdf3 = new  SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.add(Calendar.YEAR,year);
        c.set(Calendar.MONTH,month-1);
        c.set(Calendar.DAY_OF_MONTH,day);
        return sdf3.format(c.getTime());
    }


}
